package com.greenyoung.pwiki.elasticsearch.index.controller;

import com.greenyoung.pwiki.common.entity.Result;
import com.greenyoung.pwiki.elasticsearch.index.service.ElIndexRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/el/record")
@Api("Elasticsearch索引记录")
public class ElIndexRecordController {
    @Autowired
    private ElIndexRecordService elIndexRecordServices;

    @GetMapping("/status")
    @ApiOperation(value = "获取索引状态信息", notes = "获取用户正在索引、索引成功、索引失败的记录个数")
    @ApiImplicitParam(name = "userId",value ="用户id，查询哪个用户的索引记录状态" )
    public Result indexStatus(@RequestParam Long userId) {
        Map<String, Integer> indexStatus = elIndexRecordServices.queryElIndexCount(userId);
        return Result.ok().put("indexStatus", indexStatus);
    }

}
